package com.his.server.utils.log;

import org.apache.commons.logging.Log;

public class LogUtils{
	
    private final String className;
    private final Log logger;
    
    public LogUtils(String clazzName, Log log)
    {
        className = clazzName;
        logger = log;
    }

    public void writeDebug(String message)
    {
        logger.debug(editMessage(message));
    }

    public void writeTrace(String message)
    {
        logger.trace(editMessage(message));
    }

    public boolean isFatalEnabled()
    {
        return logger.isFatalEnabled();
    }

    public boolean isErrorEnabled()
    {
        return logger.isErrorEnabled();
    }

    public boolean isWarnEnabled()
    {
        return logger.isWarnEnabled();
    }

    public boolean isInfoEnabled()
    {
        return logger.isInfoEnabled();
    }

    public boolean isDebugEnabled()
    {
        return logger.isDebugEnabled();
    }

    public boolean isTraceEnabled()
    {
        return logger.isTraceEnabled();
    }

    private StringBuilder editMessage(String message)
    {
        StringBuilder msg = new StringBuilder();
        msg.append(Thread.currentThread().getId());
        msg.append(',');
        msg.append(className);
        msg.append(',');
        msg.append(message);
        return msg;
    }

}